import deepcopy from 'deepcopy'
export const baseValidate = {
  name: [{
    required: true,
    message: '名称不能为空',
    trigger: 'blur'
  },
  {
    type: 'string',
    min: 2,
    max: 20,
    message: '用户名长度必须是2~20字符',
    trigger: 'blur'
  }],
  status: [
    {
      required: true,
      message: '用户状态不能为空',
      trigger: 'blur'
    },
    {
      type: 'enum',
      enum: ['NORMAL', 'LOCKED', 'DISABLE'],
      message: '选择用户状态',
      trigger: 'blur'
    }
  ],
  phone: [
    {
      max: 15,
      message: '电话不能大于15个字符',
      trigger: 'blur'
    }
  ],
  email: [
    {
      max: 20,
      message: '邮箱不能大于20个字符',
      trigger: 'blur'
    }
  ],
  sex: [
    {
      required: true,
      message: '性别不能为空',
      trigger: 'blur'
    },
    {
      type: 'enum',
      enum: ['MAN', 'WOMAN', 'UNKNOWN'],
      message: '选择性别',
      trigger: 'blur'
    }
  ],
  remarks: [
    {
      max: 255,
      message: '描述不能大于255个字符',
      trigger: 'blur'
    }
  ]

}

const notNullPassword = {
  required: true,
  message: '初始密码不能为空！',
  trigger: 'blur'
}

const lenPassword = {
  type: 'string',
  min: 6,
  max: 20,
  message: '初始密码必须是6~20个字符',
  trigger: 'blur'
}

const username = [{
  required: true,
  message: '账号不能为空',
  trigger: 'blur'
},
{
  type: 'string',
  min: 2,
  max: 20,
  message: '帐号长度必须是5~25字符',
  trigger: 'blur'
}]

export const addValidate = deepcopy(baseValidate)
addValidate.password = [notNullPassword, lenPassword]
addValidate.username = username

export const editValidate = deepcopy(baseValidate)
editValidate.password = [lenPassword]
